From 79858995b3c4fe6fdc5f5f7e634eb581b313e3b8 Mon Sep 17 00:00:00 2001 From: Kaivo Anastetiks Date: Tue, 5 Jul 2016 08:09:11 -0400 Subject: [PATCH] Add a test for invalid subcommand displayed on error. --- src/bin/cargo.rs | 2 +- tests/cargo.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 27a349d92..2c267623d 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -211,7 +211,7 @@ fn execute_subcommand(config: &Config, return Err(human(match find_closest(config, cmd) { Some(closest) => format!("no such subcommand: `{}`\n\n\t\ Did you mean `{}`?\n", cmd, closest), - None => "no such subcommand".to_string() + None => format!("no such subcommand: `{}`", cmd) }).into()) } }; diff --git a/tests/cargo.rs b/tests/cargo.rs index 029000309..09cfa168f 100644 --- a/tests/cargo.rs +++ b/tests/cargo.rs @@ -105,7 +105,7 @@ fn find_closest_biuld_to_build() { assert_that(pr, execs().with_status(101) - .with_stderr("[ERROR] no such subcommand + .with_stderr("[ERROR] no such subcommand: `biuld` Did you mean `build`? @@ -121,7 +121,18 @@ fn find_closest_dont_correct_nonsense() { assert_that(pr, execs().with_status(101) - .with_stderr("[ERROR] no such subcommand + .with_stderr("[ERROR] no such subcommand: `there-is-no-way-that-there-is-a-command-close-to-this` +")); +} + +#[test] +fn displays_subcommand_on_error() { + let mut pr = cargo_process(); + pr.arg("invalid-command"); + + assert_that(pr, + execs().with_status(101) + .with_stderr("[ERROR] no such subcommand: `invalid-command` ")); } -- 2.30.2